#ifndef OPENGL_HELPER_H
#define OPENGL_HELPER_H

#include <cstdlib>
#include <cmath>

#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/GLUT.h>
#else
#include <GL/glut.h>
#endif

namespace OGLHelper{

static GLuint bgList = 0;

static float colormap[] = {
    0, 0, 0.5625,
    0, 0, 0.6250,
    0, 0, 0.6875,
    0, 0, 0.7500,
    0, 0, 0.8125,
    0, 0, 0.8750,
    0, 0, 0.9375,
    0, 0, 1.0000,
    0, 0.0625, 1,
    0, 0.1250, 1,
    0, 0.1875, 1,
    0, 0.2500, 1,
    0, 0.3125, 1,
    0, 0.3750, 1,
    0, 0.4375, 1,
    0, 0.5000, 1,
    0, 0.5625, 1,
    0, 0.6250, 1,
    0, 0.6875, 1,
    0, 0.7500, 1,
    0, 0.8125, 1,
    0, 0.8750, 1,
    0, 0.9375, 1,
    0, 1.0000, 1,
    0.0625, 1, 0.9375,
    0.1250, 1, 0.8750,
    0.1875, 1, 0.8125,
    0.2500, 1, 0.7500,
    0.3125 ,1, 0.6875,
    0.3750, 1, 0.6250,
    0.4375, 1, 0.5625,
    0.5000, 1, 0.5000,
    0.5625, 1, 0.4375,
    0.6250, 1, 0.3750,
    0.6875, 1, 0.3125,
    0.7500, 1, 0.2500,
    0.8125, 1, 0.1875,
    0.8750, 1, 0.1250,
    0.9375, 1, 0.0625,
    1, 1, 0,
    1, 0.9375, 0,
    1, 0.8750, 0,
    1, 0.8125, 0,
    1, 0.7500, 0,
    1, 0.6875, 0,
    1, 0.6250, 0,
    1, 0.5625, 0,
    1, 0.5000, 0,
    1, 0.4375, 0,
    1, 0.3750, 0,
    1, 0.3125, 0,
    1, 0.2500, 0,
    1, 0.1875, 0,
    1, 0.1250, 0,
    1, 0.0625, 0,
    1, 0, 0,
    0.9375, 0, 0,
    0.8750, 0, 0,
    0.8125, 0, 0,
    0.7500, 0, 0,
    0.6875, 0, 0,
    0.6250, 0, 0,
    0.5625, 0, 0,
    0.5000, 0, 0
};

//get rgb color value by index (colormap generate from blue to red)
void ColorFromColormap(float &r, float &g, float &b, unsigned int index);

//draw gradual change background
void DrawBackground(float topR = 0.0f, float topG = 0.7f, float topB = 0.65f, float buttomR = 1.0f, float buttomG = 1.0f, float buttomB = 1.0f);

//determine whether a object get hitted under the cursor(winX, winY)
bool HitObject(int winX, int winY, double *retX = NULL, double *retY = NULL, double *retZ = NULL);

}

#endif
